import { RouterMount, createRouter } from "uni-simple-router";
import { verifyLogin } from "@/common/function/project";
const router = createRouter({
  platform: process.env.VUE_APP_PLATFORM,
  routes: [...ROUTES],
});
//全局路由前置守卫
router.beforeEach(async (to, _, next) => {
  // console.log("全局路由前置守卫", to, process.env.VUE_APP_PLATFORM);
  let { meta } = to;
  try {
    if (meta.verifyLogin) await verifyLogin();
    next();
  } catch (error) {
    error instanceof Function && error(() => (router.$lockStatus = false));
  }
});
export { router, RouterMount };
